<include file="/public/header" />

<div class="layui-fluid">
    <div class="layui-card">
        <!-- // 默认操作按钮 -->
        <div class="layui-card-header layuiadmin-card-header-auto ">
        <div class="layui-form">
            <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input name="name" class="layui-input" type="text" placeholder="{:__('按会员搜索')}"/>
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input name="title" class="layui-input" type="text" placeholder="{:__('按规则搜索')}"/>
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input name="contents" class="layui-input" type="text" placeholder="{:__('按备注查询')}"/>
                </div>
            </div>
            <div class="layui-inline" >
                <!-- // 默认搜索 -->
                <button class="layui-btn icon-btn" lay-filter="formSearch" lay-submit><i class="layui-icon layui-icon-search"></i>{:__('搜索')}</button>
                <!-- // 打开添加页面 -->
                <button class="layui-btn icon-btn" lay-open="" lay-title="{:__('添加规则')}" lay-area="762px,520px" lay-url="{:url('/system.apiaccess/add')}" >
                    <i class="layui-icon layui-icon-add-1"></i>{:__('添加')}
                </button>
            </div>
            </div>
        </div>   
        </div>

        <!-- // 创建数据表实例 -->
        <table id="lay-tableList" lay-filter="lay-tableList"></table>        
    </div>
</div>

<!-- // 列表状态栏 -->
<script type="text/html" id="tableStatus">
    <input type="checkbox" lay-filter="switchStatus" lay-url="{:url('/system.apiaccess/status')}" value="{{d.id}}" lay-skin="switch"
     {{d.status==1?'checked':''}}  />
</script>

<!-- // 列表工具栏 -->
<script type="text/html" id="tableBar"> 
    <a class="layui-table-text" lay-open lay-title="{:__('编辑')}" 
        lay-area="762px,520px" lay-url="{:url('/system.apiaccess/edit/')}id/{{d.id}}" >{:__('编辑')}</a>
    <div class="layui-divider layui-divider-vertical"></div>
    <a class="layui-table-text" lay-url="{:url('/system.apiaccess/del/')}id/{{d.id}}" lay-event="del" >{:__('删除')}</a>
</script>

<include file="/public/footer" />
<script>
    layui.use(['table'], function () {

        var table = layui.table;
        /*
         * 初始化表格
        */
        var isTable = table.render({
            elem: "#lay-tableList"
            ,url: "{:url('/system.apiaccess/index')}"
            ,page: true
            ,cols: [[
                {type: 'checkbox', width:45},
                {field: 'id', align: 'center',sort: true,width: 80,  title: 'ID'},
                {field: 'name', align: 'center', title: "{:__('会员名称')}"},
                {field: 'title', align: 'center', title: "{:__('接口名称')}"},
                {field: 'class', align: 'center', title: "{:__('接口地址')}"},
                {field: 'method', align: 'center',templet: function (d) {
                        var strs = ['<span class="layui-badge layui-badge-green">GET</span>', 
                                    '<span class="layui-badge layui-badge-blue">POST</span>',
                                    '<span class="layui-badge layui-badge-red">不限</span>',
                                    ];
                        return strs[d.method];
                }, title: "{:__('请求方式')}"},
                {field: 'status', align:'center', templet:'#tableStatus', title: "{:__('状态')}"},
                {field: 'ceiling', align: 'center',templet:function(d){
                    return d.ceiling == '0' ? '<div>不限</div>' : d.ceiling;
                },  title: "{:__('服务调用次数')}"},
                {field: 'createtime', align: 'center',title: "{:__('创建时间')}"},
                {align: 'center', toolbar: '#tableBar',width: 160, title: "{:__('操作')}"},
            ]]
        })

    });

</script>
